package com.timoon.sample.page;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.spring.injection.annot.SpringBean;

import com.googlecode.wicket.jquery.ui.Options;
import com.timoon.app.resource.css.CSSLocation;
import com.timoon.component.behavior.bootstrap.AbstractBootStrapBehavior;
import com.timoon.component.panel.common.DefaultEmptyPanel;
import com.timoon.page.Page1;
import com.timoon.sample.utils.SystemConfig;
import com.timoon.webcomponent.utility.form.form1.Form1Panel;
import com.timoon.webcomponent.utility.header.Header1Panel;
import com.timoon.webcomponent.utility.navs.jd.JdNavPanel;
import com.timoon.webcomponent.utility.product.discount.Discount1Panel;
import com.timoon.webcomponent.utility.product.discount.Discount1Service;
import com.timoon.webcomponent.utility.product.horizontalListPic.HorizontalListPicProductInTabPanel;
import com.timoon.webcomponent.utility.product.rank.RankPanel;
import com.timoon.webcomponent.utility.product.rank.RankService;
import com.timoon.webcomponent.utility.product.searchresult.SearchResultPanel;
import com.timoon.webcomponent.utility.product.sort.sortnav1.InsideNavsService;
import com.timoon.webcomponent.utility.product.sort.sortnav2.Sortnav2Panel;
import com.timoon.webcomponent.utility.sift.jd.JdSiftService;

/**
 *<p></p>
 *<p>url:product_sort_id,用户所选中的商品分类id</p>
 *<p>Copyright:Copyright(c)2013.4.1</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */
public class CategoryProductPage extends WebPage {
	
	private PageParameters pageParameters;
	
	public CategoryProductPage(PageParameters pageParameters) {
		// TODO Auto-generated constructor stub
		
		this.pageParameters=pageParameters;
		
		this.renderPanel();
		
	}
	
	private void renderPanel() {
		// TODO Auto-generated method stub
		
		//引用bootstrap
		this.add(new AbstractBootStrapBehavior("#ddddddd", "click", new Options()));
		
		renderHeader();
		
		//主导航
		renderMainNav();
		
		//购物车
		//this.renderShoppingCart();
		
		//搜索表单
		//this.renderSearchForm();
		
		//this.renderLogo();
		
		//商品分类
		renderProductSort();
		
		//推荐商品
		renderRecommendProduct();
		
		//商品列表
		renderProductList();
		
		this.renderRank();
		
		//店长推荐
		this.renderDiscount1();
	}
	private void renderHeader() {
		// TODO Auto-generated method stub
		add(new Header1Panel("wk_header"));
	}

	private void renderDiscount1() {
		// TODO Auto-generated method stub
		//add(new Discount1Panel("wk_discount1","店长推荐",Page1.class));
	}
	
	private void renderRank() {
		// TODO Auto-generated method stub
		add(new AjaxLazyLoadPanel("wk_rank") {
			
			@Override
			public Component getLazyLoadComponent(String arg0) {
				// TODO Auto-generated method stub
				return new RankPanel(arg0, "销售排行", Page1.class);
			}
		});
	}
	

	private void renderProductList() {
		// TODO Auto-generated method stub
		add(new SearchResultPanel("wk_product_list",this.pageParameters,this.getClass()));
	}

	private void renderRecommendProduct() {
		// TODO Auto-generated method stub
		add(new HorizontalListPicProductInTabPanel("wk_recommend_product",SystemConfig.RECOMMEND_PRODUCT_TYPE,"推荐商品", SingleProductPage.class));
	}

	private void renderProductSort() {
		// TODO Auto-generated method stub
		add(new Sortnav2Panel("wk_product_sort",CategoryProductPage.class));
	}

	private void renderMainNav() {
		// TODO Auto-generated method stub
		add(new JdNavPanel("wk_main_nav", SystemConfig.getNavParameters()));
	}

	private void renderShoppingCart() {
		// TODO Auto-generated method stub
		add(new DefaultEmptyPanel("wk_shopping_cart","购物车"));
	}

	private void renderSearchForm() {
		// TODO Auto-generated method stub
		add(new Form1Panel("wk_search_form",CategoryProductPage.class));
	}

	private void renderLogo() {
		// TODO Auto-generated method stub
		add(new DefaultEmptyPanel("wk_logo","logo"));
	}
	@Override
	public void renderHead(IHeaderResponse response) {
		// TODO Auto-generated method stub
		super.renderHead(response);
		
		response.render(CssHeaderItem.forReference(new CssResourceReference(CSSLocation.class,"web.css")));
	}
}
